<template>
  <div class="register">
    <div class="regbox">
      <div class="reg-title">
        <h2>更正商标申请/注册事项申请</h2>
      </div>
      <div class="reg-form">
        <el-form
          :model="data"
          :rules="rules"
          ref="data"
          label-width="200px"
          class="demo-ruleForm"
        >
          <el-form-item label="申请人名称：" >
            <el-input v-model="data.app_name_id"  :disabled="true"></el-input>
          </el-form-item>

          <el-form-item label="是否共有商标：" prop="comm_status">
            <el-radio-group v-model="data.comm_status">
              <el-radio label="是"></el-radio>
              <el-radio label="否"></el-radio>
            </el-radio-group>
          </el-form-item>

          <el-form-item label="商标申请号/注册号：" prop="app_code">
            <el-input v-model="data.app_code" placeholder="商标注册号"></el-input>
          </el-form-item>

          <el-form-item label="类别：" prop="category">
            <el-input v-model="data.category" placeholder="填写类别编号已 ，分隔"></el-input>
          </el-form-item>
          
          <el-form-item label="需重新制发证书文件：" prop="make_status">
            <el-radio-group v-model="data.make_status">
              <el-radio label="是"></el-radio>
              <el-radio label="否"></el-radio>
            </el-radio-group>
          </el-form-item>


          <el-form-item label="更正事项：" prop="event_corr">
            <el-input type="textarea" v-model="data.event_corr" :autosize="{ minRows: 5}"></el-input>
          </el-form-item>

          <base-upload @getFile="getFile"></base-upload>

        </el-form>
      </div>
      <div class="r-f-sutbox">
        <button class="r-f-sut" @click="upimg">提交</button>
      </div>
    </div>
  </div>
</template>

<script>
import BaseUpload from "@/components/base-component/BaseUpload";
export default {
  name: "form-correct",
  components: {
    BaseUpload
  },
  data() {
    return {
        data: {
        app_name_id: "11",
        comm_status:"是",
        app_code:"",
        event_corr:"",
        category:"",
        make_status:"是",
        docImgs:[],
        confirmImgs:[]
      },

      formData: new FormData(),

      rules: {
        app_code: [{ required: true, message: "字段不能为空", trigger: "blur" }],
        event_corr: [{ required: true, message: "字段不能为空", trigger: "blur" }],
        category: [{ required: true, message: "字段不能为空", trigger: "blur" }],
      },

    };
  },
  methods: {
    // 获取数据
    getFile(data, data2) {
      console.log(data);
      console.log(data2);

      this.data.docImgs = data;
      this.data.confirmImgs = data2;

    },
  
    // 图片上传
    upimg() {

      for (let i = 0; i < this.data.docImgs.length; i++) {
        this.formData.append("docImgs", this.data.docImgs[i]);
      }
      for (let j = 0; j < this.data.confirmImgs.length; j++) {
         this.formData.append("confirmImgs", this.data.confirmImgs[j]);
      }

      this.formData.append("app_name_id", this.data.app_name_id);
      this.formData.append("comm_status", this.data.comm_status);
      this.formData.append("app_code", this.data.app_code);
      this.formData.append("category", this.data.category);
      this.formData.append("make_status", this.data.make_status);
      this.formData.append("event_corr", this.data.event_corr);
     
      //配置请求头
      var config = {
        header: {
          "Content-Type": "multipart/form-data"
        }
      };
      // axios向后端发送数据
      this.$http
        .post(
          "http://192.168.0.102:8080/proTCorrection/update",
          this.formData,
          config
        )
        .then(function(response) {
          console.log(response);
        })
        .catch(function(error) {
          console.log(error);
        });
    }
    
  },
};
</script>

<style scoped lang="less">
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.5s;
}
.fade-enter, .fade-leave-to /* .fade-leave-active, 2.1.8 版本以下 */ {
  opacity: 0;
}
i,
em {
  font-style: normal;
}
.register {
  width: 100%;
  background-color: #e7e8eb;
  .regbox {
    width: 1240px;
    margin: 0 auto;
    background-color: #fff;
    padding: 20px;
    .reg-title {
      padding: 15px 20px;
      text-align: center;
      border-bottom: 1px solid #e7e8eb;
      h2 {
        font-size: 22px;
        font-weight: 300;
      }
    }
    .reg-form {
      width: 700px;
      margin-left: 120px;
      .el-form-item {
        margin-top: 50px;
      }
    }
    .r-f-sutbox {
      margin-top: 50px;
      text-align: center;
      .r-f-sut {
        padding: 12px 20px;
        color: #fff;
        border: none;
        outline: none;
        border-radius: 5px;
        cursor: pointer;
        background-color: #67c23a;
      }
    }
  }
}
</style>
